package com.situ.day9;

import org.junit.Test;

public class StringDemo {

    @Test
    public void test1() {
        //"java" 字符串常量对象
        String str1 = "java";
        String str2 = new String("java");
        // == 和 equals区别
        // ==比较的是地址值
        // equals比较的是字符串的内容
        System.out.println(str1 == str2);//false
        System.out.println(str1.equals(str2));//true
    }

    @Test
    public void test2() {
        String str1 = new String("Java");
        String str2 = new String("ui");
        String str3 = new String("php");
        String str4 = new String("h5");
        String str = str1 + str1 + str3 + str4;
        System.out.println(str);
    }

    @Test
    public void test3() {
        //StringBuilder StringBuffer
        //StringBuffer:线程安全
        //StringBuilder:线程不安全
        StringBuilder builder = new StringBuilder("Java");
        builder.append("ui");
        builder.append("php");
        builder.append("h5");
        System.out.println(builder);

        StringBuffer buffer = new StringBuffer("Java");
        buffer.append("ui");
        buffer.append("php");
        buffer.append("h5");
        System.out.println(buffer);
    }

    @Test
    public void test4() {
        //Math是和数学相关的工具类，里面定义了很多和数学相关的方法，都是static
        int max = Math.max(3, 5);
        System.out.println(max);

        //round四舍五入
        long num1 = Math.round(3.6);
        System.out.println(num1);
        //floor:地板  向下取整
        double num2 = Math.floor(3.6);
        System.out.println(num2);//3.0
        //ceil:天花板 向上取整
        double num3 = Math.ceil(3.2);
        System.out.println(num3);//4.0
    }

    //包装数据类型
    //Java是一个纯面向对象语言
    @Test
    public void test5() {
        int num1 = 3;
        Integer num2 = 4;
        Boolean b = true;
        // byte short  int     long  double float  char      boolean
        // Byte Short  Integer Long  Double Float  Character Boolean
        // 包装类型的默认null
    }


}
